<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "UserInformation".
 */
class UserInformation extends ActiveRecord {


    // only define rules for those attributes that
    // will receive user inputs.
    public function rules()
    {
        return [
            [['user_id', 'school', 'begin', 'finish', 'major', 'degree'], 'required'],
            [['user_id', 'degree'], 'integer'],
            [['school', 'major'], 'string', 'max' => 32],
            [['begin', 'finish'], 'string', 'max' => 16],
        ];
    }
    /**
     * @name 字段名称
     * @return array
     */
    public function attributeLabels()
    {
        return [
            'user_id' => '用户名',
            'school' => '学校',
            'begin' => '入学时间',
            'finish' => '毕业时间',
            'degree' => '学历学位',
            'major' => '专业',
        ];
    }

    /**
     * @name 获取user信息
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
        return $this->hasOne(User::className(), ['id' => 'user_id']);
    }
}